package org.lennon.demo.ddd.ticket.factory;

import org.lennon.demo.ddd.ticket.aggregate.TicketRecord;

import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

public class TicketRecordFactory {

    /**
     *
     * @param userId
     * @param extId
     * @param amount
     * @return
     */
    public static TicketRecord create(Long userId, Long extId, Integer amount) {
        return new TicketRecord(userId, extId, amount);
    }

    /**
     *
     * @param userId
     * @param extIds
     * @param signleAmount
     * @return
     */
    public static List<TicketRecord> create(Long userId, Set<Long> extIds, Integer signleAmount) {
        return extIds.stream()
                .map(
                        it -> create(userId, it, signleAmount)
                )
                .collect(Collectors.toList());
    }
}
